package com.lggry.array.branch;

public class ForDemo1 {
    public static void main(String[] args) {
        getSum();
        getOddSum();
    }

    //求1-5之间的数据和，并把求和结果在控制台输出
    public static void getSum(){
        int sum = 0;
        for(int i=1;i<=5;i++){
            sum+=i;
        }
        System.out.println(sum);
    }

    //求1-10之间的奇数和
    public static void getOddSum(){
        int sum = 0;
        for (int i=1;i<=10;i++){
            if(i % 2 == 1){
                sum+=i;
            }
        }
        System.out.println(sum);
    }
}
